{
 "cells": [
  {
   "cell_type": "markdown",
   "id": "interested-cement",
   "metadata": {},
   "source": [
    "https://leetcode.com/problems/complex-number-multiplication\n",
    "\n",
    "\n",
    "Runtime: 0 ms, faster than 100.00% of C++ online submissions for Complex Number Multiplication.\n",
    "Memory Usage: 5.9 MB, less than 59.05% of C++ online submissions for Complex Number Multiplication.\n",
    "\n",
    "\n",
    "```cpp\n",
    "#include <vector>\n",
    "#include <algorithm>\n",
    "#include <string>\n",
    "#include <map>\n",
    "#include <vector>\n",
    "#include <sstream>\n",
    "#include <iostream>\n",
    "\n",
    "using namespace std;\n",
    "\n",
    "class Solution\n",
    "{\n",
    "public:\n",
    "    string complexNumberMultiply(string a, string b)\n",
    "    {\n",
    "        //6:18\n",
    "        auto A = parse(a);\n",
    "        auto B = parse(b);\n",
    "        auto a1 = A[0];\n",
    "        auto a2 = A[1];\n",
    "        auto b1 = B[0];\n",
    "        auto b2 = B[1];\n",
    "        // str(a1 * b1 + ((a2 * b2)*(-1))) +\"+\"+ str((a1 * b2) + (a2 * b1)) + \"i\"\n",
    "        return str(a1 * b1 + ((a2 * b2) * (-1))) + \"+\" + str((a1 * b2) + (a2 * b1)) + \"i\";\n",
    "        //6:43\n",
    "    }\n",
    "\n",
    "    vector<int> parse(string s)\n",
    "    {\n",
    "        vector<int> tokens;\n",
    "        stringstream check1(s);\n",
    "        string intermediate;\n",
    "        while (getline(check1, intermediate, '+'))\n",
    "        {\n",
    "            tokens.push_back(stoi(intermediate));\n",
    "        }\n",
    "        return tokens;\n",
    "    }\n",
    "\n",
    "    string str(int integer)\n",
    "    {\n",
    "\n",
    "        stringstream ss;\n",
    "        ss << integer;\n",
    "        string s;\n",
    "        ss >> s;\n",
    "        return s;\n",
    "    }\n",
    "};\n",
    "```"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "id": "convertible-trailer",
   "metadata": {},
   "outputs": [],
   "source": []
  }
 ],
 "metadata": {
  "kernelspec": {
   "display_name": "C++17",
   "language": "C++17",
   "name": "xcpp17"
  },
  "language_info": {
   "codemirror_mode": "text/x-c++src",
   "file_extension": ".cpp",
   "mimetype": "text/x-c++src",
   "name": "c++",
   "version": "17"
  }
 },
 "nbformat": 4,
 "nbformat_minor": 5
}
